﻿
    <script src="../../../../Scripts/m_script/m_common.js" type="text/javascript"></script>
    <style type="text/css">
        .modulenode
        {
            cursor: pointer;
        }
        .smodulenode
        {
            margin-left: 5px;
            cursor: pointer;
        }
        .appnode
        {
            margin-left: 5px;
        }
        .collapse .smodulenode, .collapse .appnode
        {
            display: none;
        }
        .expand .smodulenode
        {
            display: block;
        }
        .ico_co
        {
            width: 15px;
            height: 15px;
            background-image: url(/images/collapse.gif);
            background-repeat: no-repeat;
            display: inline-block;
        }
        .ico_ex
        {
            width: 15px;
            height: 15px;
            background-image: url(/images/expand.gif);
            background-repeat: no-repeat;
            display: inline-block;
        }
        .ico_app
        {
            width: 15px;
            height: 15px;
            background-image: url(/images/appnode.png);
            background-repeat: no-repeat;
            display: inline-block;
        }
        #menu a
        {
            text-decoration: none;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            bindLeftMenu();
            $("#menu").on("click", ":first-child", function () {

                if ($(this).parent().hasClass("collapse")) {
                    $(this).parent().removeClass("collapse");
                    $(this).parent().addClass("expand");
                    $(this).children(".ico_node").removeClass("ico_co");
                    $(this).children(".ico_node").addClass("ico_ex");
                }
                else if ($(this).parent().hasClass("expand")) {
                    $(this).parent().removeClass("expand");
                    $(this).parent().addClass("collapse");
                    $(this).children(".ico_node").removeClass("ico_ex");
                    $(this).children(".ico_node").addClass("ico_co");
                }
            })
        });

        function bindLeftMenu() {
            $.getJSON("/Manage/Ajax/GetMenuData", {random:Math.random()}, function (r) {
                $(r).each(function () {
                    var module = this.Mode;
                    var app_desc = this.ResourceName;
                    var url = this.Url;
                    var menu = $("#menu");
                    var apphtml = '<div class="appnode"><span class="ico_app"></span><span><a  href="{0}" target="main">{1}</a></span></div>'.format(url, app_desc);
                    if (menu.children("[name=" + module + "]").length == 0) {
                        menu.append('<div class="modulenode collapse" name="{0}"><div><span class="ico_node ico_co"></span><span>{1}</span></div></div>'.format(module, module));
                    }
                    menu.children("[name=" + module + "]").append(apphtml);
                });
            })
        } 
    </script> 
    <div id="menu" style="width: 158px;">
    </div>

